from jinja2 import Environment, select_autoescape, PackageLoader
from sanic.response import html


# ----------jinja2配置-------------- #
env = Environment(
    loader=PackageLoader('my_jinja2.my_jinja2', '../template'),   # 'application', './template_floder'
    autoescape=select_autoescape(['html', 'xml', 'tpl'])
)


def template(tpl, **kwargs):
    _template = env.get_template(tpl)
    return html(_template.render(kwargs))
# --------------------------------- #
